﻿<navigation:Page x:Class="RialternativeSample.Views.ProductsView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                 mc:Ignorable="d"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:s="clr-namespace:FirstLook.ServiceModel.DomainServices.Client.Security;assembly=FirstLook.ServiceModel.DomainServices.Client.Security"
                 d:DesignWidth="640"
                 d:DesignHeight="480"
                 Title="Products"
                 Style="{StaticResource PageStyle}"
                 VerticalAlignment="Stretch"
                 VerticalContentAlignment="Stretch"
                 s:Authorization.RequiresAuthentication="True"
                 DataContext="{Binding ProductsViewModel, Source={StaticResource ViewModelLocator}}">
    <navigation:Page.Resources>
        <CollectionViewSource x:Key="productsCollection"
                              Source="{Binding Products}" />
    </navigation:Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <sdk:DataGrid ItemsSource="{Binding Source={StaticResource productsCollection}}"
                      AutoGenerateColumns="False"
                      IsReadOnly="True">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="Product Name"
                                        Binding="{Binding ProductName}" />
                <sdk:DataGridTextColumn Header="Quantity per unit"
                                        Binding="{Binding QuantityPerUnit}" />
                <sdk:DataGridTextColumn Header="Unit price"
                                        Binding="{Binding UnitPrice}" />
                <sdk:DataGridTextColumn Header="Units in stock"
                                        Binding="{Binding UnitsInStock}" />
                <sdk:DataGridTextColumn Header="Units in stock"
                                        Binding="{Binding UnitsInStock}" />
                <sdk:DataGridTextColumn Header="Units on order"
                                        Binding="{Binding UnitsOnOrder}" />
                <sdk:DataGridTextColumn Header="Reorder level"
                                        Binding="{Binding ReorderLevel}" />
                <sdk:DataGridTextColumn Header="Discontinued"
                                        Binding="{Binding Discontinued}" />
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
        <Grid Grid.Row="1"
              Margin="0,15,0,0">
            <!--Visibility="{Binding UserCanSeeCategoriesAndSuppliers, Converter={StaticResource BooleanToVisibilityConverter}}"-->
            <!--s:Authorization.RequiresRole="ProductManager"-->
            <Grid.Resources>
                <Style x:Key="LabelText"
                       TargetType="TextBlock">
                    <Setter Property="Foreground"
                            Value="{StaticResource NormalFontBrush}" />
                    <Setter Property="HorizontalAlignment"
                            Value="Right" />
                    <Setter Property="FontWeight"
                            Value="Bold" />
                    <Setter Property="Margin"
                            Value="0,0,5,0" />
                </Style>
                <Style x:Key="ValueText"
                       TargetType="TextBlock">
                    <Setter Property="Foreground"
                            Value="{StaticResource NormalFontBrush}" />
                    <Setter Property="HorizontalAlignment"
                            Value="Left" />
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <toolkit:HeaderedContentControl Margin="20,0,0,0"
                                            DataContext="{Binding CurrentItem.Categories, Source={StaticResource productsCollection}}">
                <toolkit:HeaderedContentControl.Header>
                    <TextBlock Text="Category"
                               FontSize="16"
                               FontWeight="Bold" />
                </toolkit:HeaderedContentControl.Header>
                <Grid Margin="50,10,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="0"
                               Text="Name : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="0"
                               Text="{Binding CategoryName}"
                               Style="{StaticResource ValueText}" />
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="1"
                               Text="Description : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="1"
                               TextWrapping="Wrap"
                               Text="{Binding Description}"
                               Style="{StaticResource ValueText}" />
                </Grid>
            </toolkit:HeaderedContentControl>
            <sdk:GridSplitter HorizontalAlignment="Right"
                              VerticalAlignment="Stretch" />
            <toolkit:HeaderedContentControl Grid.Column="1"
                                            Margin="20,0,0,0"
                                            DataContext="{Binding CurrentItem.Suppliers, Source={StaticResource productsCollection}}">
                <toolkit:HeaderedContentControl.Header>
                    <TextBlock Text="Supplier"
                               FontSize="16"
                               FontWeight="Bold" />
                </toolkit:HeaderedContentControl.Header>
                <Grid Margin="50,10,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="0"
                               Text="Company name : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="0"
                               Text="{Binding CompanyName}"
                               Style="{StaticResource ValueText}" />
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="1"
                               Text="Contact name : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="1"
                               Text="{Binding ContactName}"
                               Style="{StaticResource ValueText}" />
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="2"
                               Text="Contact title : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="2"
                               Text="{Binding ContactTitle}"
                               Style="{StaticResource ValueText}" />
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="3"
                               Text="City : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="3"
                               Text="{Binding City}"
                               Style="{StaticResource ValueText}" />
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="4"
                               Text="Phone : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="4"
                               Text="{Binding Phone}"
                               Style="{StaticResource ValueText}" />
                    <TextBlock HorizontalAlignment="Right"
                               Grid.Row="5"
                               Text="Home page : "
                               Style="{StaticResource LabelText}" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="5"
                               Text="{Binding HomePage}"
                               TextWrapping="Wrap"
                               Style="{StaticResource ValueText}" />
                </Grid>
            </toolkit:HeaderedContentControl>
        </Grid>
    </Grid>
</navigation:Page>
